package com.hz.userService.controller;

import com.hz.apiService.model.domain.TeacherDTO;
import com.hz.apiService.model.request.ApiResponse;
import com.hz.userService.domain.User;
import com.hz.userService.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@RestController
@RequestMapping("/user")
@RequiredArgsConstructor  // 使用构造器自动注入
public class TeacherController {

    @Resource
    UserService userService;

    @GetMapping("/all-teachers")
    public String allTeachers(){
        return  ApiResponse.ok(userService.allTeachers());
    }

    @GetMapping("/teacher-info")
    public String getTeacherInfo(@RequestParam("teacherId") Integer teacherId){
        TeacherDTO teacherDTO = userService.getTeacherById(teacherId);
        return teacherDTO == null ? ApiResponse.resNotFound() : ApiResponse.ok(teacherDTO);
    }
}
